<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CAN Frame Types</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="kvaser.gif"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('page_user_guide_can_frame_types_types.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">CAN Frame Types </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#section_user_guide_can_frame_types_data_frames">CAN Data Frames</a></li>
<li class="level1"><a href="#section_user_guide_can_frame_types_fd_data_frames">CAN FD Data Frames</a></li>
<li class="level1"><a href="#section_user_guide_can_frame_types_error_frame">Error Frames</a></li>
<li class="level1"><a href="#section_user_guide_can_frame_types_remote_request">Remote Requests</a></li>
<li class="level1"><a href="#section_user_guide_can_frame_types_overload_frames">Overload Frames</a></li>
<li class="level1"><a href="#section_user_guide_can_frame_types_other">Other frame features of interest</a></li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="section_user_guide_can_frame_types_data_frames"></a>
CAN Data Frames</h1>
<p>The CAN Data Frame is the most common message type, which consists of the following major parts (a few details are omitted for the sake of brevity):</p>
<ul>
<li>CAN identifier, or Arbitration Field: which determines the priority of the message when two or more nodes are contending for the bus. The Arbitration Field contains:<ul>
<li>For CAN 2.0A, an 11-bit Identifier and one bit, the RTR bit, which is dominant for data frames.</li>
<li>For CAN 2.0B, a 29-bit Identifier, with the EXT bit set, (which also contains two recessive bits: SRR and IDE) and the RTR bit.</li>
</ul>
</li>
<li>Data Field: which contains zero to eight bytes of data.</li>
<li>Data Length Code: which specifies the number of data bytes in the Data field.</li>
<li>CRC Field: which contains a 15-bit checksum calculated on most parts of the message. This checksum is used for error detection.</li>
<li>Acknowledgement Slot: Any CAN controller that has been able to correctly receive the message sends an Acknowledgement bit at the end of each message. The transmitter checks for the presence of the Acknowledge bit and retransmits the message if no acknowledge was detected.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>It is worth noting that the presence of an Acknowledgement Bit on the bus does not mean that any of the intended addressees has received the message. The only thing we know is that one or more nodes on the bus has received it correctly.</dd>
<dd>
The Identifier in the Arbitration Field is not, despite of its name, necessarily identifying the contents of the message.</dd></dl>
<h1><a class="anchor" id="section_user_guide_can_frame_types_fd_data_frames"></a>
CAN FD Data Frames</h1>
<p>A standard CAN network is limited to 1 MBit/s, with a maximum payload of 8 bytes per frame. CAN FD increases the effective data-rate by allowing longer data fields - up to 64 bytes per frame - without changing the CAN physical layer. CAN FD also retains normal CAN bus arbitration, increasing the bit-rate by switching to a shorter bit time only at the end of the arbitration process and returning to a longer bit time at the CRC Delimiter, before the receivers send their acknowledge bits. The CAN FD Data Frame settings are controlled by the <a class="el" href="canstat_8h.html#canFDMSG_xxx">canFDMSG_xxx</a> flags. A realistic bandwidth gain of 3 to 8 times what's possible in CAN will particularly benefit flashing applications.</p>
<h1><a class="anchor" id="section_user_guide_can_frame_types_error_frame"></a>
Error Frames</h1>
<p>Nearly all hardware platforms support detection of Error Frames. If an Error Frame arrives, the flag <a class="el" href="canstat_8h.html#ade1b8ed815a4bc6ada6ec666e48e9cf8">canMSG_ERROR_FRAME</a> is set in the flag argument of <a class="el" href="group___c_a_n.html#ga157d49a9343dea68ac953145e02266d8">canRead()</a>. The identifier is garbage if an Error Frame is received, but for LAPcan it happens to be 2048 plus the error code from the SJA1000.</p>
<p>Many platforms (for example, LAPcan, Leaf, and USBcan II) support transmission of Error Frames as well. To send Error Frames, set the <a class="el" href="canstat_8h.html#ade1b8ed815a4bc6ada6ec666e48e9cf8">canMSG_ERROR_FRAME</a> flag in the flag argument to <a class="el" href="group___c_a_n.html#ga62c185329d6741c90102511e2f37983e">canWrite()</a>.</p>
<p>Simply put, the Error Frame is a special message that violates the framing rules of a CAN message. It is transmitted when a node detects a fault and will cause all other nodes to detect a fault - so they will send Error Frames, too. The transmitter will then automatically try to retransmit the message. There is an elaborate scheme of error counters that ensures that a node can't destroy the bus traffic by repeatedly transmitting error frames.</p>
<p>The Error Frame consists of an Error Flag, which is 6 bits of the same value (thus violating the bit-stuffing rule) and an Error Delimiter, which is 8 recessive bits. The Error Delimiter provides some space in which the other nodes on the bus can send their Error Flags when they detect the first Error Flag.</p>
<h1><a class="anchor" id="section_user_guide_can_frame_types_remote_request"></a>
Remote Requests</h1>
<p>You can send remote requests by passing the <a class="el" href="canstat_8h.html#a687df04559a9995e0bec503655454eb3">canMSG_RTR</a> flag to <a class="el" href="group___c_a_n.html#ga62c185329d6741c90102511e2f37983e">canWrite()</a>. Received remote frames are reported by <a class="el" href="group___c_a_n.html#ga157d49a9343dea68ac953145e02266d8">canRead</a> et al using the same flag.</p>
<p>The Remote Frame is just like the Data Frame, with two important differences:</p>
<ul>
<li>is explicitly marked as a Remote Frame (the RTR bit in the Arbitration Field is recessive)</li>
<li>there is no Data Field.</li>
</ul>
<p>The intended purpose of the Remote Frame is to solicit the transmission of the corresponding Data Frame. If, say, node A transmits a Remote Frame with the Arbitration Field set to 234, then node B, if properly initialized, might respond with a Data Frame with the Arbitration Field also set to 234.</p>
<p>Remote Frames can be used to implement a type of request-response type of bus traffic management. In practice, however, the Remote Frame is little used. It is also worth noting that the CAN standard does not prescribe the behaviour outlined here. Most CAN controllers can be programmed either to automatically respond to a Remote Frame, or to notify the local CPU instead.</p>
<p>There's one catch with the Remote Frame: the Data Length Code must be set to the length of the expected response message even though no data is sent. Otherwise the arbitration will not work.</p>
<p>Sometimes it is claimed that the node responding to the Remote Frame is starting its transmission as soon as the identifier is recognized, thereby "filling up" the empty Remote Frame. This is not the case.</p>
<h1><a class="anchor" id="section_user_guide_can_frame_types_overload_frames"></a>
Overload Frames</h1>
<p>These aren't used nowadays. Certain old CAN controllers (Intel 82526) used them to delay frame processing in certain cases.</p>
<h1><a class="anchor" id="section_user_guide_can_frame_types_other"></a>
Other frame features of interest</h1>
<ul>
<li>You can send wakeup frames (used for Single-Wire CAN) if your hardware supports it, for example, a LAPcan plus a DRVcan S. Just set the <a class="el" href="canstat_8h.html#a616183e2ed8ca81976463914e47b35e1">canMSG_WAKEUP</a> flag when calling <a class="el" href="group___c_a_n.html#ga62c185329d6741c90102511e2f37983e">canWrite()</a>.</li>
<li>For "low-speed CAN" (1053/1054 type transceivers), the <a class="el" href="canstat_8h.html#a1f53f2fdeeb263cd2bf5d374e1dd59a2">canMSG_NERR</a> flag is set if a frame is received in "fault-tolerant" mode. </li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="page_canlib.html">CAN bus API (CANlib)</a></li>
    <li class="footer"> (canlib 5.38) Tue Feb 15 2022</li>
  </ul>
</div>
</body>
</html>
